<?php

if(!defined('IN_ECS'))
{
	die('Hacking attempt');
}

class exchange
{
	var $table;
	var $db;
	var $id;
	var $name;
	var $error_msg;
	
	function exchange($table,&$db,$id,$name)
	{
		$this->table	= $table;
		$this->db		= &$db;
		$this->id		= $id;
		$this->name 	= $name;
		$this->error_msg= '';
	}
	
	function is_only($col,$name,$id = 0,$where = '')
	{
		$sql = 'SELECT COUNT(*) FROM ' . $this->table . " WHERE $col = '$name'";
		$sql .= empty($id) ? '' : ' AND ' . $this->id . " <> '$id'";
		$sql .= empty($where) ? '' : ' AND ' . $where;
		
		return ($this->db->getOne($sql) == 0);
	}
	
	
}